//
//  TopImageTableViewCell.m
//  OurMenu
//
//  Created by lanou3g on 15/10/12.
//  Copyright © 2015年 尹坤. All rights reserved.
//

#import "TopImageTableViewCell.h"

@implementation TopImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    
    return self;
}


- (void)createView
{
    //成品图
    self.foodImageV = [[UIImageView alloc] init];
    [self.contentView addSubview:self.foodImageV];
    //菜名
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
//    //主料标识
//    self.mainLabel = [[UILabel alloc] init];
//    [self.contentView addSubview:self.mainLabel];
//    //配料标识
//    self.supportLabel = [[UILabel alloc] init];
//    [self.contentView addSubview:self.supportLabel];
    //主料
    self.mainMaterilsLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.mainMaterilsLabel];

    //背景图
    self.backGroundImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.backGroundImageView];
    
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.foodImageV.backgroundColor = [UIColor redColor];
    self.titleLabel.backgroundColor = [UIColor greenColor];
    self.mainMaterilsLabel.backgroundColor = [UIColor cyanColor];
    //self.mainLabel.backgroundColor = [UIColor greenColor];

         
#pragma mark - 位置
         
#warning *******手动修改 x值
    
    self.titleLabel.frame = CGRectMake(127, 120, self.titleLabel.frame.size.width, self.titleLabel.frame.size.height);
    //self.mainLabel.frame = CGRectMake(10, 180, 40, 30);
    self.mainMaterilsLabel.frame = CGRectMake(55.5, 180, self.mainMaterilsLabel.frame.size.width, self.mainMaterilsLabel.frame.size.height);
    //self.doneBtn.frame = CGRectMake(doneBtn.frame.origin.x, 20, doneBtn.frame.size.width, self.doneBtn.frame.size.height);
    self.backGroundImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 300);
    self.backGroundImageView.alpha = 1;

    //         tab.frame = CGRectMake(0, 300, tab.frame.size.width, tab.frame.size.height);
    //         tab.alpha = 1;
    //
    //         NSLog(@"width %f height %f",foodImageV.frame.size.width,foodImageV.frame.size.height);

    self.foodImageV.frame = CGRectMake(137, 10, self.foodImageV.frame.size.width * 2, self.foodImageV.frame.size.height * 2);

}

- (void) animateOnEntry
{
#pragma mark - Frames
    //set initial frames
    self.backGroundImageView.alpha = 0;
    self.backGroundImageView.frame = CGRectMake(0, 50 + MAIN_LABEL_Y_ORIGIN, self.contentView.frame.size.width, self.titleLabel.frame.size.height + self.titleLabel.frame.size.height);
#warning ******  手动修改宽度、高度
    self.titleLabel.frame = CGRectMake(70, 50 + MAIN_LABEL_Y_ORIGIN, 120, 50);
    self.mainMaterilsLabel.frame = CGRectMake(70, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height, 280, 120);
    self.foodImageV.frame = CGRectMake(10, 50 + IMAGEVIEW_Y_ORIGIN, 50, 50);
    //self.doneBtn.frame = CGRectMake(doneBtn.frame.origin.x, 0-doneBtn.frame.size.height-20, doneBtn.frame.size.width, self.doneBtn.frame.size.height);
//    tab.alpha = 0;
//    tab.frame = CGRectMake(tab.frame.origin.x, tab.frame.size.height + self.view.frame.size.height, tab.frame.size.width, tab.frame.size.height);
    
    //apply animation on ENTERING INTO THE VIEW
    [UIView animateWithDuration:0.5
                          delay:0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^(void)
     {
         
#pragma mark - 位置
         
#warning *******手动修改 x值
         self.titleLabel.frame = CGRectMake(127, 120, self.titleLabel.frame.size.width, self.titleLabel.frame.size.height);
         self.mainMaterilsLabel.frame = CGRectMake(55.5, 180, self.mainMaterilsLabel.frame.size.width, self.mainMaterilsLabel.frame.size.height);
         //self.doneBtn.frame = CGRectMake(doneBtn.frame.origin.x, 20, doneBtn.frame.size.width, self.doneBtn.frame.size.height);
         self.backGroundImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 300);
         self.backGroundImageView.alpha = 1;
         
//         tab.frame = CGRectMake(0, 300, tab.frame.size.width, tab.frame.size.height);
//         tab.alpha = 1;
//         
//         NSLog(@"width %f height %f",foodImageV.frame.size.width,foodImageV.frame.size.height);
         
         self.foodImageV.frame = CGRectMake(137, 10, self.foodImageV.frame.size.width * 2, self.foodImageV.frame.size.height * 2);
     }
                     completion:NULL];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
